home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / WorldScript.h < prev   
Text File  |  1995-07-06  |  10KB  |  357 lines

  1. /*
  2.      File:        WorldScript.h
  3.  
  4.      Contains:    WorldScript I Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __WORLDSCRIPT__
  21. #define __WORLDSCRIPT__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __TRAPS__
  30. #include <Traps.h>
  31. #endif
  32.  
  33. #ifndef __QUICKDRAWTEXT__
  34. #include <QuickdrawText.h>
  35. #endif
  36. /*    #include <MixedMode.h>                                        */
  37.  
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41.  
  42. #if PRAGMA_ALIGN_SUPPORTED
  43. #pragma options align=mac68k
  44. #endif
  45.  
  46. #if PRAGMA_IMPORT_SUPPORTED
  47. #pragma import on
  48. #endif
  49.  
  50. typedef UInt16 WSIOffset;
  51.  
  52. typedef UInt8 WSIByteCount;
  53.  
  54. typedef UInt8 WSIByteIndex;
  55.  
  56. /* offset from start of sub-table to row in state table */
  57. typedef UInt16 WSIStateOffset;
  58.  
  59. typedef UInt32 WSITableOffset;
  60.  
  61. typedef UInt16 WSISubtableOffset;
  62.  
  63. typedef UInt16 WSIGlyphcode;
  64.  
  65. typedef UInt32 WSITableIdentifiers;
  66.  
  67.  
  68. enum {
  69.     kScriptSettingsTag            = 'info',
  70.     kMetamorphosisTag            = 'mort',
  71.     kGlyphExpansionTag            = 'g2g#',
  72.     kPropertiesTag                = 'prop',
  73.     kJustificationTag            = 'kash',
  74.     kCharToGlyphTag                = 'cmap',
  75.     kGlyphToCharTag                = 'pamc',
  76.     kFindScriptRunTag            = 'fstb'
  77. };
  78.  
  79. /****             L O O K U P    T A B L E    T Y P E S        ****/
  80. enum {
  81.     WSILookupSimpleArray        = 0,                            /* a simple array indexed by glyph code */
  82.     WSILookupSegmentSingle        = 2,                            /* segment mapping to single value */
  83.     WSILookupSegmentArray        = 4,                            /* segment mapping to lookup array */
  84.     WSILookupSingleTable        = 6,                            /* sorted list of glyph, value pairs */
  85.     WSILookupTrimmedArray        = 8                                /* a simple trimmed array indexed by glyph code */
  86. };
  87.  
  88. typedef unsigned short WSILookupTableFormat;
  89.  
  90. typedef unsigned short WSILookupValue;
  91.  
  92. /* An offset from the beginning of the lookup table */
  93. typedef unsigned short WSILookupOffset;
  94.  
  95. /*    FORMAT SPECIFIC DEFINITIONS */
  96. /*
  97.         lookupSimpleArray:
  98.         
  99.         This is a simple array which maps all glyphs in the font
  100.         to lookup values.
  101.     */
  102. struct WSILookupArrayHeader {
  103.     WSILookupValue                    lookupValues[1];            /* The array of values indexed by glyph code */
  104. };
  105. typedef struct WSILookupArrayHeader WSILookupArrayHeader;
  106.  
  107. /*
  108.         lookupTrimmedArray:
  109.         
  110.         This is a single trimmed array which maps a single range
  111.         of glyhs in the font to lookup values.
  112.     */
  113. struct WSILookupTrimmedArrayHeader {
  114.     WSIGlyphcode                    firstGlyph;
  115.     WSIGlyphcode                    limitGlyph;
  116.     WSILookupValue                    valueArray[1];
  117. };
  118. typedef struct WSILookupTrimmedArrayHeader WSILookupTrimmedArrayHeader;
  119.  
  120. /* The format specific part of the subtable header */
  121. union WSILookupFormatSpecificHeader {
  122.     WSILookupArrayHeader            lookupArray;
  123.     WSILookupTrimmedArrayHeader        trimmedArray;
  124. };
  125. typedef union WSILookupFormatSpecificHeader WSILookupFormatSpecificHeader;
  126.  
  127. /* The overall subtable header */
  128. struct WSILookupTableHeader {
  129.     WSILookupTableFormat            format;                        /* table format */
  130.     WSILookupFormatSpecificHeader    fsHeader;                    /* format specific header */
  131. };
  132. typedef struct WSILookupTableHeader WSILookupTableHeader;
  133.  
  134. /****        G L Y P H    E X P A N S I O N    ****/
  135.  
  136. enum {
  137. /* fixed 1.0 */
  138.     kCurrentGlyphExpansionVersion = 0x00010000
  139. };
  140.  
  141. typedef unsigned short GlyphExpansionFormats;
  142.  
  143.  
  144. enum {
  145.     GlyphExpansionLookupFormat    = 1,
  146.     GlyphExpansionContextualFormat = 2
  147. };
  148.  
  149. struct ExpandedGlyphCluster {
  150.     WSIByteCount                    numGlyphs;
  151.     WSIByteIndex                    bestGlyph;
  152.     WSIGlyphcode                    glyphs[1];
  153. };
  154. typedef struct ExpandedGlyphCluster ExpandedGlyphCluster;
  155.  
  156. struct ExpandedGlyphOffset {
  157.     WSIGlyphcode                    glyph;
  158.     WSIOffset                        offset;                        /* offset to ExpandedGlyphCluster */
  159. };
  160. typedef struct ExpandedGlyphOffset ExpandedGlyphOffset;
  161.  
  162. struct GlyphExpansionTable {
  163.     Fixed                            version;
  164.     short                            format;
  165.     short                            expansionNumer;
  166.     short                            expansionDenom;                /* num/denom ratio for expansion <2> */
  167.     union {
  168.         struct GlyphExpansionStateTable {
  169.             WSISubtableOffset                stateTableOffset;
  170.             WSISubtableOffset                classTableOffset;
  171.             WSISubtableOffset                actionTableOffset;    /* state, class and actions tables follow here... */
  172.         }                                stateTable;
  173.         WSILookupTableHeader            lookup;                    /* expanded glyph clusters follow here... */
  174.     }                                table;
  175. };
  176. typedef struct GlyphExpansionTable GlyphExpansionTable;
  177.  
  178. /* Glyph-to-Character constants and types  */
  179.  
  180. enum {
  181.     kCurrentGlyphToCharVersion    = (Fixed)0x00010100
  182. };
  183.  
  184. typedef unsigned short GlyphToCharLookupFormats;
  185.  
  186.  
  187. enum {
  188.     kGlyphToCharLookup8Format    = 1,
  189.     kGlyphToCharLookup16Format    = 2,
  190.     kGlyphToCharLookup32Format    = 3
  191. };
  192.  
  193. typedef UInt8 GlyphToCharFontIndex;
  194.  
  195. typedef UInt8 QDGlyphcode;
  196.  
  197. struct GlyphToCharActionTable {
  198.     WSISubtableOffset                fontNameOffset;                /* offset relative to this table */
  199.     WSILookupTableHeader            actions;                    /* only support lookupSimpleArray format for now */
  200. };
  201. typedef struct GlyphToCharActionTable GlyphToCharActionTable;
  202.  
  203. struct GlyphToCharActionHeader {
  204.     short                            numTables;                    /* 0..n */
  205.     WSISubtableOffset                offsets[1];                    /* offsets from start of action table header */
  206. };
  207. typedef struct GlyphToCharActionHeader GlyphToCharActionHeader;
  208.  
  209. struct GlyphToCharHeader {
  210.     Fixed                            version;
  211.     WSISubtableOffset                actionOffset;                /* offset to GlyphToCharActionHeader */
  212.     short                            format;                        /* size of font mask */
  213.     WSILookupTableHeader            mappingTable;
  214. };
  215. typedef struct GlyphToCharHeader GlyphToCharHeader;
  216.  
  217. /* JUSTIFICATION TYPES
  218.     WorldScript supports justification of text using insertion. The justification
  219.     table specifies a insertion string to insert between 2 specified glyphs.
  220.     Each combination of inter-glyph boundary can be assigned a justification priority,
  221.     the higher the priority the more justification strings inserted at that position.
  222.     
  223.     The priorities for each inter-glyph boundary are specified by the justification table's
  224.     state table.
  225.     
  226.     Special handling is done for scripts which use spaces to justify, because the width of 
  227.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  228.     per inserting string is specified in the justification table.
  229.  
  230. */
  231.  
  232. enum {
  233. /* 1.0 not supported */
  234.     kCurrentJustificationVersion = 0x0200
  235. };
  236.  
  237. enum {
  238.     kJustificationStateTableFormat = 1
  239. };
  240.  
  241. enum {
  242. /* WSI's internal limitation <12> */
  243.     kMaxJustificationStringLength = 13
  244. };
  245.  
  246. typedef UInt8 WSIJustificationPriority;
  247.  
  248.  
  249. enum {
  250.     WSIJustificationSetMarkMask    = 0x80
  251. };
  252.  
  253. struct WSIJustificationStateEntry {
  254.     WSIJustificationPriority        markPriority;                /* non-zero priorities means insertion */
  255.     WSIJustificationPriority        priority;
  256.     WSIStateOffset                    newState;
  257. };
  258. typedef struct WSIJustificationStateEntry WSIJustificationStateEntry;
  259.  
  260. typedef unsigned short WSIJustificationClasses;
  261.  
  262.  
  263. enum {
  264.     wsiJustEndOfLineClass        = 0,
  265.     wsiJustEndOfRunClass        = 1,
  266.     wsiJustDeletedGlyphClass    = 2,
  267.     wsiJustUserDefinedClass        = 3
  268. };
  269.  
  270. typedef unsigned short WSIJustificationStates;
  271.  
  272.  
  273. enum {
  274.     wsiStartOfLineState            = 0,                            /* pre-defined states */
  275.     wsiStartOfRunState            = 1,
  276.     wsiUserDefinedState            = 2
  277. };
  278.  
  279. /* pre-multiplied: class# * sizeof(WSIJustificationStateEntry) */
  280. typedef UInt8 WSIJustificationClassOffset;
  281.  
  282. struct WSIJustificationStateTable {
  283.     short                            maxPriorities;
  284.     unsigned short                    rowWidth;                    /* width of a state table row in bytes */
  285.     short                            classTableOffset;
  286.     short                            stateTableOffset;
  287. };
  288. typedef struct WSIJustificationStateTable WSIJustificationStateTable;
  289.  
  290. struct WSIJustificationHeader {
  291.     short                            version;
  292.     short                            format;
  293.     Point                            scaling;                    /* numer/denom scaling of priority weights <7> */
  294.     unsigned short                    spacesPerInsertion;            /* # of $20 chars in justification insertion string <12> */
  295.     unsigned short                    justStringOffset;            /* offset to justification string */
  296.     WSIJustificationStateTable        stateTable;                    /* long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows */
  297. };
  298. typedef struct WSIJustificationHeader WSIJustificationHeader;
  299.  
  300. /* Line Layout's Property table version <11> */
  301.  
  302. enum {
  303. /* v1.0 */
  304.     currentPropsTableVersion    = 0x00010000
  305. };
  306.  
  307. enum {
  308. /* ??? is this right */
  309.     kCharToGlyphCurrentVersion    = 0100
  310. };
  311.  
  312. /* pass as priorityWeight to JustifyWSILayout to use script's current just setting */
  313. enum {
  314.     kScriptsDefaultJustWeight    = -1
  315. };
  316.  
  317. struct WSIGlyphInfoRec {
  318.     UInt8                            qdChar;
  319.     SInt8                            rightToLeft;                /* !0 means rightToLeft, 0 means leftToRight */
  320.     short                            fontID;
  321.     short                            originalOffset;                /* or negative original offset if not in original text input */
  322.     unsigned short                    unused;                        /* long-align */
  323. };
  324. typedef struct WSIGlyphInfoRec WSIGlyphInfoRec, **WSIGlyphInfoHandle;
  325.  
  326. typedef Handle WSILayoutHandle;
  327.  
  328. extern pascal WSILayoutHandle NewWSILayout(WSILayoutHandle layoutH, Ptr text, short txLength, short lineDirection, unsigned long flags, OSErr *err)
  329.  FOURWORDINLINE(0x2F3C, 0X8414, 0x0040, 0xA8B5);
  330. extern pascal WSILayoutHandle JustifyWSILayout(WSILayoutHandle layoutH, Fixed slop, short priorityWeight, JustStyleCode styleRunPosition, Point numer, Point denom, OSErr *err)
  331.  FOURWORDINLINE(0x2F3C, 0x8418, 0x0042, 0xA8B5);
  332. extern pascal Fixed MeasureWSILayout(WSILayoutHandle layoutH, Point numer, Point denom)
  333.  FOURWORDINLINE(0x2F3C, 0x840C, 0x0044, 0xA8B5);
  334. extern pascal void DrawWSILayout(WSILayoutHandle layoutH, Point numer, Point denom)
  335.  FOURWORDINLINE(0x2F3C, 0x800C, 0x0046, 0xA8B5);
  336. /* "low-level" routines */
  337. extern pascal WSIGlyphInfoHandle GetWSILayoutParts(WSILayoutHandle layoutH, WSIGlyphInfoHandle destH, short *numGlyphs, OSErr *err)
  338.  FOURWORDINLINE(0x2F3C, 0x8410, 0x0048, 0xA8B5);
  339. extern pascal void DrawWSIGlyphs(short length, Ptr qdCodes, Point numer, Point denom)
  340.  FOURWORDINLINE(0x2F3C, 0x800E, 0x004A, 0xA8B5);
  341. extern pascal Fixed xMeasureWSIGlyphs(Ptr *qdCodes, short length, Point numer, Point denom)
  342.  FOURWORDINLINE(0x2F3C, 0x840E, 0x004C, 0xA8B5);
  343.  
  344. #if PRAGMA_IMPORT_SUPPORTED
  345. #pragma import off
  346. #endif
  347.  
  348. #if PRAGMA_ALIGN_SUPPORTED
  349. #pragma options align=reset
  350. #endif
  351.  
  352. #ifdef __cplusplus
  353. }
  354. #endif
  355.  
  356. #endif /* __WORLDSCRIPT__ */
  357.